#pragma once

#include <iostream>
#include <string>
#include <cstring>
#include <cassert>
#include <cerrno>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

#define NAME_PIPE "/tmp/mypipe_4-17"

bool creatFifo(const std::string& path)
{
    umask(0);
    int n = mkfifo(path.c_str(),0600);
    if(n == 0) return true;
    else
    {
        std::cout << "errno: " << errno << " err string: "<< strerror(errno) << std::endl;
        return false;
    }
}

void removeFifo(const std::string& path)
{
    int n = unlink(path.c_str());
    assert(n == 0);
    (void)n;
    // if(n == 0)
    // {
    //     std::cout << "the pipe is deleted! " << std::endl;
    // }
    // else
    // {
    //     std::cout << "the pipe is not feleted! " << std::endl;
    //     std::cerr << "errno: " << errno << " str err: "<< strerror(errno);
    // }
    //保证n在debug和release下都被使用,避免warning
}